

function s() {
    var allCount = document.querySelector("#allCount");
    var allCountNum = 0;
    var qb = document.querySelectorAll("#qb .kl");
    for (var i = 0;i < qb.length;i++){
        //单价
        var price = qb[i].children[2].children[0].innerHTML;
        //数量
        var num = qb[i].children[3].children[0].value;
        //小计
        var count = qb[i].children[4].children[0].innerHTML = (price * num).toFixed(2);
        //总价
        allCountNum += Number(count);
    }
    allCount.innerHTML = allCountNum.toFixed(2)
}
s();

//获取数量的功能
//获取table里面的所有input
var ipt = document.querySelectorAll("#qb .nu");
for (var k = 0;k < ipt.length;k++){
    ipt[k].addEventListener('keyup',s);
}


function c() {
    var sk = document.querySelector("#sk span");
    var sk1 = document.querySelectorAll(".to tr").length;
    sk.innerHTML = sk1;
}
c();

var cc= document.querySelector('.to');
var del = document.querySelectorAll(".del");
for (var j = 0;j<del.length;j++){
    del[j].addEventListener('click',function () {
        cc.removeChild(this.parentNode);
        s();
        c();
    })
}

